$('.notice-list').on('click', function() {
	layer.open({
		type: 2,
		anim: -1,
		title: '公告详情',
		closeBtn: true,
		offset: 'r',
		shade: 0.3,
		move: false,
		shadeClose: false,
		area: '70%',
		skin: "layui-anim layui-anim-rl layui-layer-adminRight",
		content: article_uri + '?article_id=' + $(this).attr('data-id')
	})
})

// 统计产品总数
send_info(count_site_goods_uri, {}, function(data) {
	$('.product-num span').html(data.count);
})
send_info(count_order_num_and_money_url, {}, function(data) {
	$('.order-price-sum span').html(data.data.order_all_money / 100)
	$('.order-num span').html(data.data.order_num)
})
send_info(count_member_uri, {}, function(data) {
	$('.member-num span').html(data.count);
})






/*        layer.open({
                type: 2,  //可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                title: ['通知', 'font-size:14px; color:orange;'],//数组第二项可以写任意css样式；如果你不想显示标题栏，你可以title: false
                content: article_uri+'?article_id=52',
                area: [ '60%', '600px' ],
                btn: ['确定', '取消'],
                
                })
*/
// 统计每年成交金额
var create_echarts_order_money = function() {
	var echart_goods = echarts.init(document.getElementById('echarts_order_money'));
	echart_goods.setOption({
		title: {
			text: '每年成交金额（亿元）'
		},
		tooltip: {
			trigger: 'axis',
			formatter: "{c}亿元"
		},
		xAxis: {
			type: 'category',
			data: []
		},
		yAxis: {
			type: 'value'
		},
		series: {
			data: [],
			type: 'bar'
		}
	});
	echart_goods.showLoading();
	send_info(count_year_order_money_url, {}, function(data) {
		var data_source = data.data;
		echart_goods.setOption({
			series: {
				data: data.count
			},
			xAxis: {
				data: data.data
			}
		});
		echart_goods.hideLoading();
	});

}
create_echarts_order_money();
// 分类销量占比
var create_echarts_goods_category = function() {
	var echart_goods_category = echarts.init(document.getElementById('echarts_goods_category'));
	echart_goods_category.setOption({
		title: {
			text: '各品类销售占比（%）'
		},
		aria: {
			show: true
		},

		renderer: 'svg',
		tooltip: {
			trigger: 'item',
			formatter: "{b}:({d}%)"
		},
		legend: {
			type: 'scroll',
			orient: 'vertical',
			left: 10,
			top: 60,
			bottom: 20,
		},
		series: {
			radius: ['40%', '70%'],
			type: 'pie',
			minAngle: 2,
			itemStyle: {
				emphasis: {
					shadowBlur: 10,
					shadowOffsetX: 0,
					shadowColor: 'rgba(0, 0, 0, 0.5)'
				}
			}
		}
	});
	echart_goods_category.showLoading();
	send_info(count_cate_sale_url, {}, function(data) {
		console.log(data)
		var data_source = data.data;
		echart_goods_category.setOption({
			series: {
				data: data_source
			}
		});
		echart_goods_category.hideLoading();
	});
}
create_echarts_goods_category();

// 统计活跃用户
var create_echarts_member = function() {
	var echart_member = echarts.init(document.getElementById('echarts_member'));
	echart_member.setOption({
		title: {
			text: '活跃用户(万)'
		},
		tooltip: {
			trigger: 'axis',
			formatter: "{b}：{c}万"
		},
		xAxis: {
			type: 'category',
			data: []
		},
		yAxis: {
			type: 'value'
		},
		series: {
			data: [],
			type: 'bar'
		}
	});
	echart_member.showLoading();
	send_info(count_user_active_url, {}, function(data) {
		var data_source = data.data;
		echart_member.setOption({
			series: {
				data: data.count
			},
			xAxis: {
				data: data.data
			}
		});
		echart_member.hideLoading();
	});
}
create_echarts_member();

// 统计上架商品
var create_echarts_up_goods = function() {
	var echart_up_goods = echarts.init(document.getElementById('echarts_up_goods'));
	echart_up_goods.setOption({
		title: {
			text: '上架商品(万)'
		},
		tooltip: {
			trigger: 'axis',
			formatter: "{b}：{c}万"
		},
		xAxis: {
			type: 'category',
			data: []
		},
		yAxis: {
			type: 'value'
		},
		series: {
			data: [],
			type: 'bar'
		}
	});
	echart_up_goods.showLoading();
	send_info(count_up_goods_url, {}, function(data) {
		var data_source = data.data;
		echart_up_goods.setOption({
			series: {
				data: data.count
			},
			xAxis: {
				data: data.data
			}
		});
		echart_up_goods.hideLoading();
	});
}
create_echarts_up_goods();


var create_sale_top20_echart = function() {
	var echart_goods_sale_top20 = echarts.init(document.getElementById('goods_sale_top20'));
	echart_goods_sale_top20.setOption({
		title: {
			text: '销售排行',
			subtext: 'TOP20'
		},
		tooltip: {
			trigger: 'item',
			formatter: "{b}:<br />{a}销量：{c}"
		},
		legend: {
			type: 'scroll',
			orient: 'horizontal',
			left: 90,
			top: 10,
			selectedMode: 'single'
		},
		grid: {
			left: '10px',
			right: '20px',
			bottom: '10px',
			containLabel: true
		},
		xAxis: {
			type: 'value',
			boundaryGap: [0, 0.01]
		},
		yAxis: {
			type: 'category',
			minInterval: 1,
			inverse: true,
			axisLabel: {
				interval: 0,
				rotate: 30
			},
		},
		series: []
	});
	echart_goods_sale_top20.showLoading();
	send_info(count_goods_top20, {}, function(data) {
		echart_goods_sale_top20.setOption({
			series: data.data,
			yAxis: {
				data: data.msg
			}
		})
		echart_goods_sale_top20.hideLoading();
	})
}
//create_sale_top20_echart();
var select_types = 'day';
var create_order_price_list_echart = function() {
	var order_price_list_echart = echarts.init(document.getElementById('order_price_list'));
	order_price_list_echart.setOption({
		title: {
			text: '订单信息',
			subtext: '',
			triggerEvent: true,
			subtextStyle: {
				color: '#FF5722'
			}
		},
		tooltip: {
			trigger: 'axis',
			axisPointer: {
				type: 'cross',
				label: {
					backgroundColor: '#283b56'
				}
			}
		},
		legend: {
			type: 'scroll',
			orient: 'horizontal',
			left: 90,
			top: 10,
			right: 10,
		},
		xAxis: {
			type: 'category',
			axisLabel: {
				interval: 0,
				rotate: 60
			},
		},
		yAxis: [{
				type: 'value',
				name: '数量',
				nameLocation: 'middle',
				nameTextStyle: {
					backgroundColor: '#FF5722',
					color: '#ffffff',
					padding: [0, 12, 3, 12],
				}
			},
			{
				type: 'value',
				name: '金额',
				nameLocation: 'middle',
				nameTextStyle: {
					backgroundColor: '#FF5722',
					color: '#ffffff',
					padding: [0, 12, 3, 12],
				}
			}
		],
		grid: {
			left: '10px',
			right: '20px',
			bottom: '10px',
			containLabel: true
		},
		series: []
	});

	order_price_list_echart.showLoading();
	send_info(count_site_order_list_uri, {
		select_types: select_types
	}, function(data) {
		order_price_list_echart.setOption({
			title: {
				subtext: select_types == 'day' ? '近一月统计' : '近一年统计',
			},
			legend: {
				data: data.count
			},
			xAxis: {
				data: data.msg
			},
			series: data.data
		});
		order_price_list_echart.hideLoading();
	})
	order_price_list_echart.on('click', function(params) {
		if (select_types == 'day') {
			select_types = 'month';
		} else {
			select_types = 'day';
		}
		order_price_list_echart.showLoading();
		send_info(count_site_order_list_uri, {
			select_types: select_types
		}, function(data) {
			order_price_list_echart.setOption({
				title: {
					subtext: select_types == 'day' ? '近一月统计' : '近一年统计',
				},
				legend: {
					data: data.count
				},
				xAxis: {
					data: data.msg
				},
				series: data.data
			});
			order_price_list_echart.hideLoading();
		})
	})
}
//create_order_price_list_echart();

// 校验是否有未读的月度合同
send_info(check_month_contract_url, {}, (res) => {
	if (res.data != 0) {
		layer.confirm('月度合同以生成，请及时查看')
	}
})